/**
 * Title:<br>
 * Description:<br>
 * Copyright © Xiamen Dripstill  NetWorks Co.,Ltd.
 * @Create:2018-07-07<br>
 * @author:Sun Yijing<br>
 * @version: Object v1.0.0<br>
 * <br>
 * 修改历史:<br>
 * 修改人		修改日期		修改描述<br>
 * -----------------------------------<br>
 * <br>
 * <br>
 */
package com.yoooya.base.model.po.third;


import com.yoooya.base.model.po.BasePo;
import com.yoooya.base.utils.DateUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 微信访问token
 */
public class AccessTokenPo extends BasePo implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * id
	 */
	private Long id;

	/**
	 * 编码
	 */
	private String code;

	/**
	 * 企业ID
	 */
	private String corpId;

	/**
	 * 凭证密钥
	 */
	private String corpSecret;

	/**
	 * 代理Id
	 */
	private Integer agentId;

	/**
	 * appId
	 */
	private String appId;

	/**
	 * token
	 */
	private String token;

	/**
	 * 访问token
	 */
	private String accessToken;

	/**
	 * aesKey
	 */
	private String aesKey;

	/**
	 * oauth2redirectUri
	 */
	private String oauth2redirectUri;

	/**
	 * jsapiTicketExpiresTime
	 */
	private Long jsapiTicketExpiresTime;

	/**
	 * 过期时间
	 */
	private Long expiresIn;

	/**
	 * 生成时间
	 */
	private Long time;

	/**
	 * 创建时间
	 */
	private Date createTime;

	/**
	 * 修改时间
	 */
	private Date modifyTime;

	/**
	 * @return id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 *            id
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return 编码
	 */
	public String getCode() {
		return code;
	}

	/**
	 * @param code
	 *            编码
	 */
	public void setCode(String code) {
		this.code = code;
	}

	/**
	 * @return 企业ID
	 */
	public String getCorpId() {
		return corpId;
	}

	/**
	 * @param corpId
	 *            企业ID
	 */
	public void setCorpId(String corpId) {
		this.corpId = corpId;
	}

	/**
	 * @return 凭证密钥
	 */
	public String getCorpSecret() {
		return corpSecret;
	}

	/**
	 * @param corpSecret
	 *            凭证密钥
	 */
	public void setCorpSecret(String corpSecret) {
		this.corpSecret = corpSecret;
	}

	/**
	 * @return 代理Id
	 */
	public Integer getAgentId() {
		return agentId;
	}

	/**
	 * @param agentId
	 *            代理Id
	 */
	public void setAgentId(Integer agentId) {
		this.agentId = agentId;
	}

	/**
	 * @return appId
	 */
	public String getAppId() {
		return appId;
	}

	/**
	 * @param appId
	 *            appId
	 */
	public void setAppId(String appId) {
		this.appId = appId;
	}

	/**
	 * @return token
	 */
	public String getToken() {
		return token;
	}

	/**
	 * @param token
	 *            token
	 */
	public void setToken(String token) {
		this.token = token;
	}

	/**
	 * @return 访问token
	 */
	public String getAccessToken() {
		return accessToken;
	}

	/**
	 * @param accessToken
	 *            访问token
	 */
	public void setAccessToken(String accessToken) {
		this.accessToken = accessToken;
	}

	/**
	 * @return aesKey
	 */
	public String getAesKey() {
		return aesKey;
	}

	/**
	 * @param aesKey
	 *            aesKey
	 */
	public void setAesKey(String aesKey) {
		this.aesKey = aesKey;
	}

	/**
	 * @return oauth2redirectUri
	 */
	public String getOauth2redirectUri() {
		return oauth2redirectUri;
	}

	/**
	 * @param oauth2redirectUri
	 *            oauth2redirectUri
	 */
	public void setOauth2redirectUri(String oauth2redirectUri) {
		this.oauth2redirectUri = oauth2redirectUri;
	}

	/**
	 * @return jsapiTicketExpiresTime
	 */
	public Long getJsapiTicketExpiresTime() {
		return jsapiTicketExpiresTime;
	}

	/**
	 * @param jsapiTicketExpiresTime
	 *            jsapiTicketExpiresTime
	 */
	public void setJsapiTicketExpiresTime(Long jsapiTicketExpiresTime) {
		this.jsapiTicketExpiresTime = jsapiTicketExpiresTime;
	}

	/**
	 * @return 过期时间
	 */
	public Long getExpiresIn() {
		return expiresIn;
	}

	/**
	 * @param expiresIn
	 *            过期时间
	 */
	public void setExpiresIn(Long expiresIn) {
		this.expiresIn = expiresIn;
	}

	/**
	 * @return 生成时间
	 */
	public Long getTime() {
		return time;
	}

	/**
	 * @param time
	 *            生成时间
	 */
	public void setTime(Long time) {
		this.time = time;
	}

	/**
	 * @return 创建时间
	 */
	public Date getCreateTime() {
		return createTime;
	}

	/**
	 * @param createTime
	 *            创建时间
	 */
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	/**
	 * @return 修改时间
	 */
	public Date getModifyTime() {
		return modifyTime;
	}

	/**
	 * @param modifyTime
	 *            修改时间
	 */
	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}

	public boolean isExpires() {
		return DateUtils.getSecondTime() - time > expiresIn - 120;
	}
}